<template>
	<view class="success-container">
		<!-- 成功图标 -->
		<view class="icon-container">
			<image src="https://cdn8.axureshop.com/demo/1689476/images/%E7%BB%93%E6%9E%9C/u4418.png"
				class="success-icon" mode="aspectFit"></image>
		</view>

		<!-- 标题 -->
		<view class="title">{{ title }}</view>

		<!-- 描述文字 -->
		<view class="description">{{ description }}</view>

		<!-- 按钮区域 -->
		<view class="button-container">
			<!-- 主要按钮 -->
			<button class="primary-btn" @click="handlePrimaryAction">
				{{ primaryButtonText }}
			</button>

			<!-- 次要按钮 -->
			<button class="secondary-btn" @click="handleSecondaryAction" v-if="showSecondaryButton">
				{{ secondaryButtonText }}
			</button>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'

// 响应式数据
const title = ref('提交成功')
const description = ref('您的申请已提交')
const primaryButtonText = ref('确定')
const secondaryButtonText = ref('返回首页')
const showSecondaryButton = ref(true)
const primaryUrl = ref('')
// 服务数据
const serviceData=ref({})

// 页面加载时接收参数
onLoad((options) => {
	// 自定义标题
	if (options.title) {
		title.value = decodeURIComponent(options.title)
	}

	// 自定义描述
	if (options.description) {
		description.value = decodeURIComponent(options.description)
	}

	// 自定义主按钮文字
	if (options.primaryText) {
		primaryButtonText.value = decodeURIComponent(options.primaryText)
	}

	// 自定义次要按钮文字
	if (options.secondaryText) {
		secondaryButtonText.value = decodeURIComponent(options.secondaryText)
	}

	// 主按钮跳转地址
	if (options.primaryUrl) {
		primaryUrl.value = decodeURIComponent(options.primaryUrl)
	}

	// 是否显示次要按钮
	if (options.showSecondary === 'false') {
		showSecondaryButton.value = false
	}
	
	// // if(options.serviceData){
	// 	serviceData.value= JSON.parse(options.serviceData);
	// 	console.log(888,serviceData.value);
		
	// }
	
	
})




// 主要按钮点击事件
const handlePrimaryAction = () => {
	if (primaryUrl.value) {
		// 如果有自定义URL，跳转到指定页面
		uni.navigateTo({
			url: primaryUrl.value
		})
	} else {
		// 默认返回上一页
		uni.navigateBack()
	}
}

// 次要按钮点击事件（固定跳转到首页）
const handleSecondaryAction = () => {
	uni.reLaunch({
		url: '/pages/home/home'
	})
}
</script>

<style scoped>
.success-container {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40rpx;
	background-color: #fff;
}

.icon-container {
	margin-bottom: 60rpx;
}

.success-icon {
	width: 120rpx;
	height: 120rpx;
	display: block;
}

.title {
	font-size: 48rpx;
	font-weight: 600;
	color: #333;
	margin-bottom: 24rpx;
	text-align: center;
}

.description {
	font-size: 28rpx;
	color: #666;
	text-align: center;
	line-height: 1.6;
	margin-bottom: 80rpx;
	max-width: 500rpx;
}

.button-container {
	width: 100%;
	max-width: 600rpx;
}

.primary-btn {
	width: 100%;
	height: 88rpx;
	background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
	color: #fff;
	border: none;
	border-radius: 12rpx;
	font-size: 32rpx;
	font-weight: 500;
	margin-bottom: 24rpx;
	box-shadow: 0 4rpx 12rpx rgba(74, 144, 226, 0.3);
}

.primary-btn:active {
	transform: translateY(2rpx);
	box-shadow: 0 2rpx 8rpx rgba(74, 144, 226, 0.3);
}

.secondary-btn {
	width: 100%;
	height: 88rpx;
	background-color: transparent;
	color: #666;
	border: 2rpx solid #e0e0e0;
	border-radius: 12rpx;
	font-size: 32rpx;
	font-weight: 400;
}

.secondary-btn:active {
	background-color: #f5f5f5;
}
</style>
